package com.joysw.ui;

import java.util.ArrayList;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import butterknife.ButterKnife;
import butterknife.InjectView;

import com.joysw.R;
import com.joysw.models.GoodsModel;
import com.joysw.ui.adapter.ShopGridViewAdapter;
import com.joysw.view.TitleBarView;
import com.nostra13.universalimageloader.core.ImageLoader;

/**   
 * @Title: FoodsDetailActivity.java 
 * @Package com.joysw.ui 
 * @Description: 产品详细页面
 * @author LIMINGYAN  
 * @date 2015年3月28日 上午7:35:57 
 * @version V1.0   
 */
public class ShopDetailActivity extends BaseActivity{
	@InjectView(R.id.shop_title_bar)
	TitleBarView title_bar_view;
	@InjectView(R.id.show_shop_info)
	RelativeLayout show_shop_info;
	@InjectView(R.id.show_shop_img)
	ImageView mTitleImage;
	@InjectView(R.id.grid_view)
	GridView grid_view;
	
	private ArrayList<GoodsModel> goodsData=new ArrayList<GoodsModel>();
	
	@Override
	protected void onCreate(Bundle arg0) {
		// TODO Auto-generated method stub
		super.onCreate(arg0);
		setContentView(R.layout.activity_shop_detail);
		ButterKnife.inject(this);
		
		initView();
	}

	private void initView() {
		
		String testUrl = "http://pic6.nipic.com/20100401/4589785_001230731291_2.jpg";
		ImageLoader.getInstance().displayImage(testUrl, mTitleImage);//加载头部图片
		title_bar_view.setTitleText(R.string.shop_detail_title);
		title_bar_view.setBtnLeft(R.drawable.back, R.string.back);
		title_bar_view.setBtnRight(R.drawable.search);
		title_bar_view.setBtnLeftOnclickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				finish();
			}
		});
		title_bar_view.setBtnRightOnclickListener(new OnClickListener() {
			
			@Override
			public void onClick(View arg0) {
				startActivity(new Intent(ShopDetailActivity.this, GoodsSearchActivity.class));
			}
		});
		show_shop_info.getBackground().setAlpha(200);
		
		for (int i = 0; i < 9; i++) {
			GoodsModel goods = new GoodsModel();
			goods.setGoods_info("testtesttestestetswstststtsstt");
			goods.setGoods_price("1.99");
			goods.setImage_url("http://pic6.nipic.com/20100401/4589785_001230731291_2.jpg");
			goodsData.add(goods);
		}
		ShopGridViewAdapter mAdapter = new ShopGridViewAdapter(ShopDetailActivity.this, goodsData);
		grid_view.setAdapter(mAdapter);
		grid_view.setFocusable(false);
	}
}
